package com.example.mapper;

import com.example.entity.StudentAnswer;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author： wzz
 * @date： 2021-12-04 15:25
 */

public interface StudentAnswerMapper {


    @Select("select distinct (video) from studentanswer where studentNumber=#{studentNumber} and book_name=#{book_name} and menu_topic=#{menu_topic}")
    Integer getVideoTime(String studentNumber,String book_name,String menu_topic);
    /**
     * 添加学生单选题答案
     * @param studentAnswer
     * @return
     */
    int insertOption(StudentAnswer studentAnswer);

    @Insert("insert into studentanswer(studentNumber,menu_topic,book_name,type,questionNo,video,studentAnswer)" +
            "values(#{studentNumber},#{menu_topic},#{book_name},#{type},#{questionNo},#{video},#{studentAnswer})")
    int insertMu(StudentAnswer studentAnswer);

    /**
     *
     * @param studentNumber
     * @return
     */
    List<StudentAnswer> getAnswers(String studentNumber,String book_name,String menu_topic);


    int updateVideoDuration(String studentNumber, String book_name, String menu_topic,Integer duration);

    @Update("update studentanswer set score=#{score} where studentNumber=#{studentNumber}" +
            "and book_name = #{book_name} and menu_topic=#{menu_topic} and questionNo=#{questionNo}")
    Integer updateScore(StudentAnswer studentAnswer);


    @Select("select * from studentanswer where book_name=#{book_name} and (type =3 or type =4)")
    @Results(value = {
            @Result(column = "studentNumber",property = "studentNumber"),
            @Result(column = "book_name",property = "book_name"),
            @Result(column = "menu_topic",property = "menu_topic"),
            @Result(column = "questionNo",property = "questionNo"),
            @Result(column = "type",property = "type"),
            @Result(column = "studentAnswer",property = "studentAnswer"),
            @Result(column = "score",property = "score"),
    })
    List<StudentAnswer> IsCheck(String book_name);



}
